// import com.alibaba.druid.sql.ast.SQLStatement;
// import com.alibaba.druid.sql.ast.statement.*;
// import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlDeleteStatement;
// import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlInsertStatement;
// import com.alibaba.druid.sql.dialect.mysql.ast.statement.MySqlUpdateStatement;

#include "MySqlStatementType.h"
#include "../../../../ast/SQLStatement.h"

// select statement
MySqlStatementType_ptr MySqlStatementType::SELECT = MySqlStatementType_ptr(new MySqlStatementType(1ULL << 0, make_string_ptr("SQLSelectStatement")));
// update statement
MySqlStatementType_ptr MySqlStatementType::UPDATE = MySqlStatementType_ptr(new MySqlStatementType(1ULL << 0, make_string_ptr("MySqlUpdateStatement")));
// insert statement
MySqlStatementType_ptr MySqlStatementType::INSERT = MySqlStatementType_ptr(new MySqlStatementType(1ULL << 0, make_string_ptr("MySqlInsertStatement")));
// delete statement
MySqlStatementType_ptr MySqlStatementType::DELETE = MySqlStatementType_ptr(new MySqlStatementType(1ULL << 0, make_string_ptr("MySqlDeleteStatement")));
// while statement
MySqlStatementType_ptr MySqlStatementType::WHILE = MySqlStatementType_ptr(new MySqlStatementType(1ULL << 0, make_string_ptr("SQLWhileStatement")));
// begin-end
MySqlStatementType_ptr MySqlStatementType::IF = MySqlStatementType_ptr(new MySqlStatementType(1ULL << 0, make_string_ptr("SQLIfStatement")));
// begin-end
MySqlStatementType_ptr MySqlStatementType::LOOP = MySqlStatementType_ptr(new MySqlStatementType(1ULL << 0, make_string_ptr("SQLLoopStatement")));
// begin-end
MySqlStatementType_ptr MySqlStatementType::BLOCK = MySqlStatementType_ptr(new MySqlStatementType(1ULL << 0, make_string_ptr("SQLBlockStatement")));
// declare statement
MySqlStatementType_ptr MySqlStatementType::DECLARE = MySqlStatementType_ptr(new MySqlStatementType(1ULL << 0, make_string_ptr("MySqlDeclareStatement")));
// select into
MySqlStatementType_ptr MySqlStatementType::SELECTINTO = MySqlStatementType_ptr(new MySqlStatementType(1ULL << 0, make_string_ptr("MySqlSelectIntoStatement")));
// case
MySqlStatementType_ptr MySqlStatementType::CASE = MySqlStatementType_ptr(new MySqlStatementType(1ULL << 0, make_string_ptr("MySqlCaseStatement")));

MySqlStatementType_ptr MySqlStatementType::UNDEFINED = MySqlStatementType_ptr(new MySqlStatementType(1ULL << 0, make_string_ptr("UNDEFINED")));

MySqlStatementType::MySqlStatementType()
    : MySqlStatementType(0, nullptr)
{
}

MySqlStatementType::MySqlStatementType(uint64_t mask, string_ptr name)
{
  this->mask = mask;
  this->name = name;
}

MySqlStatementType_ptr MySqlStatementType::getType(SQLStatement_ptr stmt)
{
  if (stmt->getClass()->c_str() == "SQLSelectStatement")
  {
    return MySqlStatementType::SELECT;
  }
  else if (stmt->getClass()->c_str() == "MySqlUpdateStatement")
  {
    return MySqlStatementType::UPDATE;
  }
  else if (stmt->getClass()->c_str() == "MySqlInsertStatement")
  {
    return MySqlStatementType::INSERT;
  }
  else if (stmt->getClass()->c_str() == "MySqlDeleteStatement")
  {
    return MySqlStatementType::DELETE;
  }
  else if (stmt->getClass()->c_str() == "SQLWhileStatement")
  {
    return MySqlStatementType::WHILE;
  }
  else if (stmt->getClass()->c_str() == "SQLIfStatement")
  {
    return MySqlStatementType::IF;
  }
  else if (stmt->getClass()->c_str() == "SQLLoopStatement")
  {
    return MySqlStatementType::LOOP;
  }
  else if (stmt->getClass()->c_str() == "SQLBlockStatement")
  {
    return MySqlStatementType::BLOCK;
  }
  else if (stmt->getClass()->c_str() == "MySqlDeclareStatement")
  {
    return MySqlStatementType::DECLARE;
  }
  else if (stmt->getClass()->c_str() == "MySqlSelectIntoStatement")
  {
    return MySqlStatementType::SELECTINTO;
  }
  else if (stmt->getClass()->c_str() == "MySqlCaseStatement")
  {
    return MySqlStatementType::CASE;
  }
  else
  {
    return MySqlStatementType::UNDEFINED;
  }
}
